<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %> 
<%@ taglib prefix="dict" uri="/WEB-INF/tld/dict.tld" %>      
<c:set var="ctx" value="${pageContext.request.contextPath}"/> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="include.jsp"/>

	

	<script>
		$(function(){
			
		});
		
		function openTab(moduleCode){			
			$.ajax({
				type: "POST",
				url: '${ctx}/module/getByModuleCode',
				dataType:"json",
				data:{
					moduleCode : moduleCode					
				},
				success: function(result) {
					debugger;
					if(result){
						if(result.moduleName != null && result.url != null){
							selectTab(result.moduleName,result.url);
						}else{
							alert("资源对应的URL，Title不能为空！");
						}
					}else{
						alert("资源编码对应的数据不存在！");
					}
  				}
			});
		}
		
		function selectTab(title,url){
			var t =parent.$('#index_tabs');
			if (t.tabs('exists', title)) {
				t.tabs('select', title);
				parent.$.messager.progress('close');
			} else {
				var _url = url;
				if(_url.charAt(0)=='/'){
					_url = '${ctx}' +_url;
				}
				addIframeTab(title,_url);		
			}	
		}
		
		function addIframeTab(title,url){
			var t =parent.$('#index_tabs');
			//var t = $('#index_tabs');
			t.tabs('addIframeTab',{
				//tab参数为一对象，其属性同于原生add方法参数
				tab:{
	                title:title,
	                closable:true,
	                tools:[{
	                    iconCls:'icon-mini-refresh',
	                    handler:function(e){
	                        var title = $(e.target).parent().parent().text();
	                        t.tabs('updateIframeTab',{'which':title});
	                    }
	                }]
	            },
				//iframe参数用于设置iframe信息，包含：
				//src[iframe地址],frameBorder[iframe边框,，默认值为0],delay[淡入淡出效果时间]
				//height[iframe高度，默认值为100%],width[iframe宽度，默认值为100%]
				iframe:{src:url}
			});
	        t.tabs('addEventParam');        
		}
	</script>
	<style>	
		
    .lay2{
       width:1000px; 
       height:100px; 
       //border:1px solid #FF6699;
	   margin:0 auto;
	   margin-top:50px;
	   padding: 30px;
	   //display:flex;justify-content:center;align-items:center;/*div中的div居中*/
     }   
    
	
	.horizontal_green{
        float:left;//添加float样式即可实现水平排列
        border:1px solid black;
        margin-left:120px;
		width: 140px; 
		height: 80px;
		//background-color: green;
		text-align: center;/*让文字水平居中*/
		
	    position:relative
    }
	
</style>
</head>
<body class="easyui-layout">
	<div data-options="region:'center',fit:true" border="false">
		<div class="lay2">
			<shiro:hasPermission name="CncEcharts:toRealTimeRunStateBar">
 				<div class="horizontal_green"><img onclick="openTab('CncEcharts:toRealTimeRunStateBar')" src="${ctx}/images/run.png" alt="图片" style="vertical-align:middle;" height="80" width="140"/></div> 	
			</shiro:hasPermission>
			<shiro:hasPermission name="CncEcharts:toRealTimeOutput">
				<div class="horizontal_green"><img onclick="openTab('CncEcharts:toRealTimeOutput')"src="${ctx}/images/chanliang.png" alt="图片" style="vertical-align:middle;" height="80" width="140"/></div>
			</shiro:hasPermission>
			<shiro:hasPermission name="ProdMstr:toProdMstrList">
				<div class="horizontal_green"><img onclick="openTab('ProdMstr:toProdMstrList')"src="${ctx}/images/guanli.png" alt="图片" style="vertical-align:middle;" height="80" width="140"/></div>
			</shiro:hasPermission>
		</div>  
	    <div class="lay2">
	    	<shiro:hasPermission name="CncEcharts:toRealTimeRunState">
				<div class="horizontal_green"><img onclick="openTab('CncEcharts:toRealTimeRunState')"src="${ctx}/images/daochu.png" alt="图片" style="vertical-align:middle;" height="80" width="140"/></div>
			</shiro:hasPermission>
			<shiro:hasPermission name="MachInfo:toMachInfoList">
				<div class="horizontal_green"><img onclick="openTab('MachInfo:toMachInfoList')"src="${ctx}/images/xinzen.png" alt="图片" style="vertical-align:middle;" height="80" width="140"/></div>
			</shiro:hasPermission>		
			<div class="horizontal_green"><img onclick="openTab('qaderp')"src="${ctx}/images/qaderp.png" alt="图片" style="vertical-align:middle;" height="80" width="140"/></div>					
		</div>  
	</div>
</body>
</html>